package com.advaita.license;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class Customer implements PathwayOptions {
	String user = "";
	public LicenseKey licenseInfo = new LicenseKey();

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public LicenseKey getLicenseInfo() {
		return licenseInfo;
	}

	public void setLicenseInfo(LicenseKey licenseInfo) {
		this.licenseInfo = licenseInfo;
	}

	// ------------------------------------------------------------------------------------------------------------------
	// ------------------------------------------------------------------------------------------------------------------

	protected static List<Selection> addToList(List<Selection> newList,
			String[] availableOptions) {
		for (String availableOptionIterator : availableOptions) {
			Selection clientSelection = new Selection();
			clientSelection.setSelection(availableOptionIterator);
			clientSelection.setIsEnabled(false);
			newList.add(clientSelection);
		}
		return newList;
	}

	// ------------------------------------------------------------------------------------------------------------------

	public static void populateBlankCustomer(Customer testCustomer) {
		ArrayList<Selection> testCustomerOrganism = new ArrayList<Selection>();
		ArrayList<Selection> testCustomerMicroArray = new ArrayList<Selection>();
		ArrayList<Selection> testCustomerGeneID = new ArrayList<Selection>();
		ArrayList<Selection> testCustomerPathwayDB = new ArrayList<Selection>();
		ArrayList<Selection> testCustomerAnalysis = new ArrayList<Selection>();

		testCustomer.user = "";
		testCustomer.licenseInfo.setKey("No Key Set Yet");
		testCustomer.licenseInfo.setMacAddress("No Mac Address Set Yet");

		addToList(testCustomerOrganism, ORGANISM);
		addToList(testCustomerMicroArray, MICROARRAY);
		addToList(testCustomerGeneID, GENEID);
		addToList(testCustomerPathwayDB, PATHWAYDB);
		addToList(testCustomerAnalysis, ANALYSIS);

		testCustomer.licenseInfo.setOrganisms(testCustomerOrganism);
		testCustomer.licenseInfo.setMicroArray(testCustomerMicroArray);
		testCustomer.licenseInfo.setGeneID(testCustomerGeneID);
		testCustomer.licenseInfo.setDatabase(testCustomerPathwayDB);
		testCustomer.licenseInfo.setAnalysis(testCustomerAnalysis);
	}

	// ------------------------------------------------------------------------------------------------------------------

	public static void showSelections(Customer customer) {
		// test print
		System.out.println("UserName : " + customer.user);

		// Show MAC Address
		System.out.println("MAC Address : "
				+ customer.licenseInfo.getMacAddress());

		// Show Expiration Date
		DateFormat dateFormat = new SimpleDateFormat("MM/dd/yy");
		System.out.println("Expiration Date : "
				+ dateFormat.format(customer.licenseInfo.getExpDate()));

		// Show SuperSecretCode
		System.out.println("SuperSecretCode : " + customer.licenseInfo.getKey()
				+ " , ( length = " + customer.licenseInfo.key.length() + " )");

		// Show Customer's Selections
		for (Selection organismIterator : customer.licenseInfo.getOrganisms()) {
			System.out.println("Organism : " + organismIterator.getSelection()
					+ "  ( " + organismIterator.getIsEnabled() + " )");
		}
		;
	
		
		for (Selection microArrayIterator : customer.licenseInfo
				.getMicroArray()) {
			System.out.println("MicroArray : "
					+ microArrayIterator.getSelection() + "  ( "
					+ microArrayIterator.getIsEnabled() + " )");
		}
		;

		for (Selection geneIDIterator : customer.licenseInfo.getGeneID()) {
			System.out.println("Gene ID : " + geneIDIterator.getSelection()
					+ "  ( " + geneIDIterator.getIsEnabled() + " )");
		}
		;

		for (Selection pathwayDBIterator : customer.licenseInfo.getDatabase()) {
			System.out.println("Pathway DB : "
					+ pathwayDBIterator.getSelection() + "  ( "
					+ pathwayDBIterator.getIsEnabled() + " )");
		}
		;

		for (Selection analysisIterator : customer.licenseInfo.getAnalysis()) {
			System.out.println("Analysis : " + analysisIterator.getSelection()
					+ "  ( " + analysisIterator.getIsEnabled() + " )");
		}
		;

		// System.out.println( "First Organism : " +
		// customer.licenseInfo.getOrganisms().get(1).getSelection() + "," +
		// customer.licenseInfo.getOrganisms().get(1).getIsEnabled() );

	}

	// ------------------------------------------------------------------------------------------------------------------

}
